package com.hexacta.hrs.sandbox.tasks2.data;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.hexacta.hrs.sandbox.tasks2.model.Activity;
import com.hexacta.hrs.sandbox.tasks2.model.Task;

@SuppressWarnings("unchecked")
public class ActivityDaoImpl extends HibernateDaoSupport implements ActivityDao {

	public List<Activity> findAll() {
		return getHibernateTemplate().find(
				"from " + Activity.class.getSimpleName());
	}

	public Activity findById(Long id) {
		return (Activity) getHibernateTemplate().get(Activity.class, id);
	}

	public void persistActivity(Activity activity) {
		getHibernateTemplate().saveOrUpdate(activity);

	}

	public void initialize(Activity activity) {
		for (Task task : activity.getTasks()) {
			task.getId();
		}

	}

}
